<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>${siteName!""}|快递管理-编辑快递订单</title>
<#include "../common/header.ftl"/>
    <script type="text/javascript" src="/admin/js/jquery.min.js"></script>
    <script type="text/javascript" src="/home/js/city-picker.data.js"></script>
    <script type="text/javascript" src="/home/js/city-picker.js"></script>
    <link rel="stylesheet" type="text/css" href="/home/branch/css/city-picker.css">
</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar">

            <!-- logo -->
            <div id="logo" class="sidebar-header">
                <a href="/system/index"><img src="/static/admin/images/logo-sidebar.png" title="${siteName!""}"
                                          alt="${siteName!""}"/></a>
            </div>
            <div class="lyear-layout-sidebar-scroll">
        <#include "../common/left-menu.ftl"/>
            </div>

        </aside>
        <!--End 左侧导航-->
    
    <#include "../common/header-menu.ftl"/>

        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-header"><h4>编辑快递订单</h4></div>
                            <div class="card-body">
                                <form id="express-mail-order-edit-form" method="post" class="row">
                                    <input type="hidden" name="id" value="${expressMailOrder.id}">
                                    <div class="input-group m-b-10">
                                        <span class="input-group-addon">收件人手机号</span>
                                        <input type="text" class="form-control required" id="recipientsMobile" name="recipientsMobile"
                                               value="${expressMailOrder.recipientsMobile}" placeholder="请输入收件人手机号" tips="请填写收件人手机号"/>
                                    </div>

                                    <div class="input-group m-b-10">
                                        <span class="input-group-addon">收件人省市区</span>
                                        <input type="text" class="form-control required"
                                               data-toggle="city-picker" id="recipientsFullAddress" value="${expressMailOrder.recipientsFullAddress}" readonly name="recipientsFullAddress" value=""/>
                                    </div>

                                    <div class="input-group m-b-10">
                                        <span class="input-group-addon">收件人详细地址</span>
                                        <input type="text" class="form-control required" id="recipientsAddress" name="recipientsAddress"
                                               value="${expressMailOrder.recipientsAddress}" maxlength="60" placeholder="请输入收件人详细地址" tips="请填写收件人详细地址"/>
                                    </div>

                                    <div class="form-group col-md-12">
                                        <button type="button" class="btn btn-primary ajax-post"
                                                id="add-form-submit-btn">确 定
                                        </button>
                                        <button type="button" class="btn btn-default"
                                                onclick="javascript:history.back(-1);return false;">返 回
                                        </button>
                                    </div>
                                </form>

                            </div>
                        </div>
                    </div>

                </div>

            </div>

        </main>
        <!--End 页面主要内容-->
    </div>
</div>
<#include "../common/footer.ftl"/>
<script type="text/javascript" src="/static/admin/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="/static/admin/js/main.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {





        //提交按钮监听事件
        $("#add-form-submit-btn").click(function () {

            if ($("#recipientsFullAddress").val() == "") {
                showErrorMsg("请选择收件人省市区");
                return;
            }

            if ($("#recipientsFullAddress").val().split('/').length != 3){
                showErrorMsg("收件人省市区请选择完整");
                return;
            }

            if (!checkForm("express-mail-order-edit-form")) {
                return;
            }

            if ($("input[name='recipientsMobile']").val() && !$("input[name='recipientsMobile']").val().match(/^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/)) {
                showErrorMsg("请输入有效的手机号码");
                return
            }

            var data = $("#express-mail-order-edit-form").serialize();
            $.ajax({
                url: 'edit',
                type: 'POST',
                data: data,
                dataType: 'json',
                success: function (data) {
                    if (data.code == 0) {
                        showSuccessMsg('快递订单编辑成功!', function () {
                            window.location.href = '/admin/buyOff/list';
                        })
                    } else {
                        showErrorMsg(data.msg);
                    }
                },
                error: function (data) {
                    alert('网络错误!');
                }
            });
        });

    });
</script>
</body>
</html>